#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

class MinStack {
private:
	int _currentMin;
	vector<int> _container;
public:
	MinStack() :
		_currentMin(10e9),
		_container()
	{
		_container.reserve(140);
	}
	void push(int x) {
		if (_container.size() + 5 > _container.capacity())
			_container.reserve(_container.capacity() + 20);
		if (_currentMin > x)
			_currentMin = x;
		_container.push_back(x);
	}
	void pop() {
		int elem = _container.back();
		_container.pop_back();
		if (elem == _currentMin){
			_currentMin = 10e9;
			for (int i = 0; i < _container.size(); ++i){
				if (_currentMin > _container[i]) _currentMin = _container[i];
			}
		}
	}

	int top() {
		return _container.back();
	}

	int getMin() {
		return _currentMin;
	}
};

int main(int argc, char** argv){
	MinStack stack;
	stack.push(2);
	stack.push(0);
	stack.push(3);
	stack.push(0);
	cout << stack.getMin() << ' ';
	stack.pop();
	cout << stack.getMin() << ' ';
	stack.pop();
	cout << stack.getMin() << ' ';
	stack.pop();
	cout << stack.getMin() << ' ';
	return 0;
}